package com.java.yz.day13.ketang;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

/*
`           字节缓冲输入流:InputStream
                            -- FileInputStream
                            -- BufferedInputStream
 */
public class BufferedInputStreamDemo1 {
    public static void main(String[] args) {
        //BufferedInputStream(InputStream in)  使用这个构造方法
        //创建一个 BufferedInputStream 并保存其参数，即输入流 in 以供以后使用。
        BufferedInputStream bis = null;
        try {
            bis = new BufferedInputStream(new FileInputStream("src/com/java/yz/day13/ketang/c.txt"));
            //在这里读入数据
            byte[] bytes = new byte[1024];
            int i =0;
            while ((i=bis.read(bytes))!=-1){
                String s = new String(bytes,0,i);
                System.out.println(s);
            }

        }catch (IOException e){
            e.printStackTrace();
        }finally {
            if (bis != null){
                try {
                    bis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }



    }
}
